
//
// 130728 - AH - (Created).
//

package org.japril.jutil.pulse;

/**
 * <p>
 *   Default
 *   {@link Product} implementation.
 * </p>
 * @author Arne Halvorsen (AH)
 */
public class DefaultProduct implements Product
{
  private String m_type;
  
  private Object m_data;
  
  /**
   * <p>
   *   Constructor.
   * </p>
   * @param type {@link #getType()}.
   * @param data {@link #getData()}.
   */
  public DefaultProduct(String type, Object data)
  {
	if (type==null)
	{
	  throw new NullPointerException("type");	
	}
	if (data==null)
	{
	  throw new NullPointerException("data");	
	}
	
    m_type=type;
    m_data=data;
  }
  
  /**
   * <p>
   *   Sets type.
   * </p>
   * @param type Type.
   * @return {@code this}.
   */
  public final Product setType(String type)
  {
    if (type==null)
	{
	  throw new NullPointerException("type");	
	}
	
    m_type=type;
    
	return this;
  }
  
  /**
   * <p>
   *   Sets data.
   * </p>
   * @param data Data.
   * @return {@code this}.
   */
  public final Product setData(Object data)
  {
    if (data==null)
	{
	  throw new NullPointerException("data");	
	}
	
    m_data=data;
    
	return this;
  }
  
  @Override
  public String toString()
  {
    return new StringBuilder("type=").append("type=").append(m_type)
      .append(", data=").append(m_data).toString();
  }

  // Specified in Product.
  public final String getType(){ return m_type; }

  // Specified in Product.
  public final Object getData(){ return m_data; }

}
